﻿using System;
using System.Collections;
using System.Data;
using System.Data.Common;
using System.Data.Odbc;

namespace app.scrum
{
    public class Setting
    {
        private static Hashtable cache = new Hashtable();
        private static ScrumObject sObj = new ScrumObject();

        public static string settingName_ProductId = "ProductId"; 

        public static string getCurrentProductId(string settingName)
        {
            string settingValue = String.Empty;
            /*if (cache[settingName] != null)
            {
                settingValue = Convert.ToString(cache[settingName]);
            }*/
            //else
            //{
                sObj.tableName = ScrumObject.objectName_Settings;
                sObj.readCmdText = "select name__c ,value from " + ScrumObject.objectName_Settings;
                ArrayList list = sObj.read();
                foreach (ScrumObject setting in list)
                {
                    string name = Convert.ToString(ScrumObjectHelper.getScrumFieldValue(setting, "name__c"));
                    string value = Convert.ToString(ScrumObjectHelper.getScrumFieldValue(setting, "value"));
                    if (!cache.ContainsKey(name))
                    {
                        cache.Add(name, value);
                    }
                    if (String.Equals(settingName, name))
                    {
                        settingValue = value;
                    }
                }
//            }
            return settingValue;
        }

   
    }
}